<?php
/**
 *  Reg
 *  Provides a regisrty for magic that can also store Caches
 * 
 * @author Carl
 */
 
Class Reg {

	private static $items = array();
	private static $cache = array();
	
	/**
	* Set data to the registry
	* 
	* @param $key string|array
	* @param $value mixed
	*/
	public static function set($key,$value=null){
		if (is_array($key)){
			self::$items = array_merge($key, self::$items);
	    }else {
			self::$items[$key] = $value;
		}
	}
	/**
	* Get data from the cache
	* 
	* @param $key string
	* @return mixed
	*/
	public static function get($key){
		if(isset(self::$items[$key])) {
			return self::$items[$key];
		} else {
			return null;
		}
	}
	/**
	* Get a Cache from the registry
	* 
	* @param $key string
	* @return Cache
	*/
	public static function cache($key){
		if(isset(self::$cache[$key])) {
			return self::$cache[$key];
		} else {
			self::$cache[$key] = new Cache();
			return self::$cache[$key];
		}
	}
}
